package com.wn.controller;

import com.wn.bean.Result;
import com.wn.exception.BuildDeleteException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author yellow Docter
 * @date 2024-07-03
 * @desc 蜗牛创想：www.woniuxy.com
 *   全局异常处理的 controller
 *   1、@RestControllerAdvice 标记全局异常处理的类
 *   2、写处理异常的方法
 *   3、在方法上面添加注解 捕获指定的异常
 *        @ExceptionHandler(value = BuildDeleteException.class) 指定捕获的异常
 */
@RestControllerAdvice
public class ExceptionController {

    @ExceptionHandler(value = BuildDeleteException.class)
    public Result<String> handlerDelete(Exception e){
        String message = e.getMessage();
        return Result.fail(message);
    }

}
